home *** CD-ROM | disk | FTP | other *** search
- Path: rover.ucs.ualberta.ca!news
- From: ryangall@gpu.srv.ualberta.ca (Ryan Gallagher)
- Newsgroups: comp.lang.c++,ualberta.cmput.201
- Subject: class/function pointer help!
- Date: 29 Mar 1996 21:44:39 GMT
- Organization: University of Alberta, Edmonton, Canada
- Message-ID: <4jhlk7$1eke@pulp.ucs.ualberta.ca>
- NNTP-Posting-Host: async1-11.remote.ualberta.ca
- Mime-Version: 1.0
- X-Newsreader: WinVN 0.99.2
-
- Hi, I have a class that uses a function pointer. The problem Im having is
- that the pointer doesnt want to access the function when the function is a
- local function to the calling class. Here is what I mean....
-
- class expression
- {
- public:
-
- string S;
- list L;
- .
- .
- int initlist();
- .
- int isexpr(int);
- };
-
-
- list, and string are both classes.
-
- char * string::POP( int (* separator)(int c) )
- {
-
- int n=0,m=0,r,size=strlen(S);
- char *A,*B,*C;
-
- A=new char[size+1]; // allocate space for strings A & B
- .
- .
-
-
- // find the first occurence of a separator character
- while(!(*separator)(A[n]) && A[n]) n++;
-
- .
- .
- .
- return A;
- }
-
- // heres the calling function
-
- int expression::initlist(void)
- {
- char *temp;
- float F;
- char C;
-
- L.init();
-
- while((temp=S.POP( ::isexpr )))
- {
- F=C=0;
- assert(convert(F,C,temp));
- L.Add(L.Assign(F,C));
- delete[] temp;
- }
-
- return 0;
- }
-
-
- this works when I define isexpr(int) globally, but I want to beable to
- call function expression::isexpr(int).....when I do this...
-
- while((temp=S.POP( isexpr )))
- {
-
- the compiler say:" member function must be called or its address taken."
-
- how do I declare the member function as a function pointer?!
-
-
-
-
- thanks
- ------
- Please mail me back if possible.
-
-
-
-
-